﻿using System.Windows;
using System.Windows.Interactivity;

namespace Expression.Samples.Physics.Behaviors {
	public class PhysicsContextBehavior: Behavior<FrameworkElement> {

		public static readonly DependencyProperty GravityProperty = DependencyProperty.Register("Gravity", typeof(double), typeof(PhysicsContextBehavior), new PropertyMetadata(10.0d));

		public double Gravity {
			get { return (double)this.GetValue(PhysicsContextBehavior.GravityProperty); }
			set { this.SetValue(PhysicsContextBehavior.GravityProperty, value); }
		}


		protected override void OnAttached() {
			base.OnAttached();

			PhysicsContext context = new PhysicsContext();
			context.Gravity = this.Gravity;

			PhysicsContext.SetPhysicsContext(this.AssociatedObject, context);
		}
	}
}
